Function.RegisterNamespace("System.Script.Attributes");

System.Script.Attributes.Attribute=function(){
    // Public members
    this.Name;
    this.Target;

    // ctor
    function Attribute(name,target){
        this.Name=name||this.Name||'';
        this.Target=target||this.Target||getTarget(this);
    }
    Attribute.apply(this,arguments);

    // Public methods
    this.BeforeInvoke=function(context){
        // no-op
    };

    this.AfterInvoke=function(context){
        // no-op
    };
    
    // Private methods
    function getTarget(attribute){
        var map={};
        var caller=getTarget;
        while(caller&&!map[caller]){
            if(caller.caller==System.Script.Attributes.DecoratedFunction){
                return caller.Decoration;
            }
            map[caller]=true;
            caller=caller.caller;
        }
        return null;
    }
};

System.Script.Attributes.Attribute.Implement(System.Script.Attributes.IAttribute,"System.Script.Attributes.Attribute");